package com.demo.datastructure.reorder.countingSort;

import java.util.Arrays;

/**
 * @author ljr
 * @version 1.0
 * @description: 三色旗问题
 * @date 2021/10/8 15:08
 */
public class MyCountingSort4{

    public static void main(String[] args) {
        Character[] afterHandleLetterAndLetter = handleLetterAndLetter(new Character[]{'a', 'A', '1', 'b', 'B', 'g', '6', 't', '8', 'L', 'd'});
        System.out.println(Arrays.toString(afterHandleLetterAndLetter));
    }

    private static Character[] handleLetterAndLetter(Character[] characters) {
        int min = 0;
        int index = 0;
        int max = characters.length-1;
        while(index <= max){
            if(Character.isLowerCase(characters[index])){
                Character value = characters[index];
                characters[index++] = characters[min];
                characters[min++] = value;
            }else if(Character.isDigit(characters[index])){
                index++;
            }else{
                Character value = characters[index];
                characters[index] = characters[max];
                characters[max--] = value;
            }
        }
        return characters;
       /* for(int i = 0; i < characters.length; i++){
            if(!Character.isLowerCase(characters[i])){
                continue;
            }
            Character value = characters[min];
            characters[min++] = characters[i];
            characters[i] = value;
        }

        for(int i = characters.length-1; i >= 0; i--){
            if(Character.isLowerCase(characters[i]) || Character.isDigit(characters[i])){
                continue;
            }
            Character value = characters[max];
            characters[max--] = characters[i];
            characters[i] = value;
        }
        return characters;*/
    }
}
